/**
 * 首页个人服务 2022-07-23 by 杨佳 
 * email:   2337604439@qq.com
 */
 module.exports = {
    //  计算评论数量
    countComment: async (ctx) => {
       let [comment] = await  ctx.db.query("SELECT COUNT(id) AS number FROM t_post_comment WHERE state=1");
       await ctx.db.query("UPDATE t_mine SET comment_number = ?", comment[0].number); 
    },
    //  计算文章数量
    countPost: async (ctx) => {
        let [post] = await  ctx.db.query("SELECT count(id) as count FROM t_post WHERE type = 'blog' AND state= ?",ctx.constant.post.STATE.normal);
        await ctx.db.query("UPDATE t_mine SET post_number = ?", post[0].count); 
     },
   // 计算浏览数量
   countBrowse: async (ctx) => {
      let [browse] = await  ctx.db.query("SELECT COUNT(DISTINCT ip) as count FROM t_post_browse");
      await ctx.db.query("UPDATE t_mine SET browse_number = ? ", browse[0].count); 
   }
 }